package com.s.core.root.strategy.factor.point;

import com.s.core.root.data._AllData;
import com.s.core.root.data._BasePoint;
import com.s.core.root.data._PicN;
import com.s.core.root.data._PointN;
import com.s.core.root.strategy.base.Factor;
import com.s.core.root.strategy.base.Feature;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Comparator;
import java.util.List;

/**
 * Point特征：描述point的成交量是最大值
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class F_Point_Max implements Factor, Feature {
    private int pos;

    @Override
    public void process(_AllData allData) {
        for (_PicN picN : allData.picNMap.values()) {
            process(picN.getPointNList1());
            process(picN.getPointNList2());
        }
    }

    private void process(List<_PointN> pointNList) {
        if (pointNList.size() < 2) {
            return;
        }
        pointNList.stream().filter(t -> !t.isTp()).
                max(Comparator.comparing(_BasePoint::vol)).
                ifPresent(maxPoint -> maxPoint.addFeature(new F_Point_Max()));
    }
}
